Ticket: 8156
In case of non-tx alerts, we try to loop over all the txs to find
the xff header. Do not start from tx_id 0, but from min_id
as AppLayerParserTransactionsCleanup to skip txs that were freed
(cherry picked from commit
3b1a6c1711b8f7d0bde4cb05f15cf50c751eda60)
Origin: upstream, https://github.com/OISF/suricata/commit/
44d0c81f537f230e9215c769453fb4d7214217a1.patch
Bug: https://redmine.openinfosecfoundation.org/issues/8156
Subject: Upstream fix for CVE-2026-22261 part 1
Gbp-Pq: Name CVE-2026-22261_1.patch
int HttpXFFGetIP(const Flow *f, HttpXFFCfg *xff_cfg, char *dstbuf, int dstbuflen)
{
HtpState *htp_state = NULL;
- uint64_t tx_id = 0;
+ uint64_t tx_id = AppLayerParserGetMinId(f->alparser);
uint64_t total_txs = 0;
htp_state = (HtpState *)FlowGetAppState(f);
SCReturnCT((pstate == NULL) ? 0 : pstate->log_id, "uint64_t");
}
+uint64_t AppLayerParserGetMinId(AppLayerParserState *pstate)
+{
+ SCEnter();
+
+ SCReturnCT((pstate == NULL) ? 0 : pstate->min_id, "uint64_t");
+}
+
void AppLayerParserSetTransactionLogId(AppLayerParserState *pstate, uint64_t tx_id)
{
SCEnter();
uint64_t AppLayerParserGetTransactionLogId(AppLayerParserState *pstate);
+uint64_t AppLayerParserGetMinId(AppLayerParserState *pstate);
void AppLayerParserSetTransactionLogId(AppLayerParserState *pstate, uint64_t tx_id);
uint64_t AppLayerParserGetTransactionInspectId(AppLayerParserState *pstate, uint8_t direction);